package com.design.strategy;

/**
 * Created by yijy on 2017/12/5.
 */
public class ArrayList implements Collection{
    Object obj[] = new Object[10];
    int index=0;

    @Override
    public void add(Object o){
        if(index==obj.length){
            Object newObj[] = new Object[obj.length*2];
            System.arraycopy(obj,0,newObj,0,obj.length);
            obj = newObj;
        }
        obj[index] = o;
        index++;
    }

    @Override
    public int size(){
        return index;
    }

    @Override
    public Iterator itertor() {
        Itr it = new Itr();
        return it;
    }

    private class Itr implements Iterator{

        @Override
        public Object next() {
            return null;
        }

        @Override
        public boolean hasNext() {
            return false;
        }
    }
//    @Override
//    public Iterator itertor() {
//        return null;
//    }
}
